home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / xdme_1.84_src.lha / XDME / Src / Menu / MenuCom.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-04  |  29.6 KB  |  1,509 lines

  1. /******************************************************************************
  2.  
  3.     MODUL
  4.     menucom.c
  5.  
  6.     DESCRIPTION
  7.     [X]DME command interface for menubase.c
  8.  
  9.     NOTES
  10.     experimental status
  11.  
  12.     in zukunft koennte es moeglich sein,
  13.     einen einzigen namensparameter zu akzeptieren,
  14.     der dann ueber split_menu_names in seine
  15.     komponenten aufgespalten wuerde
  16.  
  17.     BUGS
  18.     IMPORTANT
  19.         we cannot actually react on ERRORs !!
  20.  
  21.     TODO
  22.     include some error()-calls
  23.     support checks
  24.  
  25.     EXAMPLES
  26.  
  27.     description of the user-commands:
  28.  
  29.     the commands below might get other names;
  30.     if so, please update their descriptions according
  31.     to the names they are used in command.c
  32.  
  33. *!***************************************************************************
  34. *!
  35. *!  MENUES:
  36. *!  ******
  37. *!
  38. *!  the following commands allow access to [X]DME's menustructures
  39. *!  that way it is possible for each user to create an individual
  40. *!  GUI for "his" [X]DME, for "his" programming language and for
  41. *!  his wishes.
  42. *!
  43. *! >MENUDELHDR menuname
  44. *!
  45. *!    delete a menuheader and all associated items (and subitems)
  46. *!
  47. *!    menuheaders are created by using their names in item or
  48. *!    subitem definitions
  49. *!
  50. *! >MENUDEL    menuname itemname
  51. *! >MENUDELBAR menuname                 (obsolete)
  52. *!
  53. *!    delete a menuitem-entry
  54. *!    DELBAR deletes the first itembar in a menu's itemlist
  55. *!    DEL deletes the menuitem with the name itemname
  56. *!        if itemname is a subitem-carrier, all subs are deleted, too
  57. *!
  58. *!    You can delete all items of a menu, if You call MENUDELHDR
  59. *!
  60. *! >MENUDELSUB      menuname itemname subname        (obsolete)
  61. *! >MENUDELSUBBAR menuname itemname            (obsolete)
  62. *!
  63. *!    delete a submenu-entry
  64. *!    DELSUBBAR deletes the first submenubar in a menuitem's subitemlist
  65. *!    DELSUB deletes the submenu with the name subname
  66. *!
  67. *!    You can delete all an item's subitem if You MENUDEL the carrying item
  68. *!
  69. *! >MENUADD   menuname itemname subname command
  70. *! >MENUBAR   menuname itemname             (obsolete)
  71. *! >MENUCHECK menuname itemname subname command     (obsolete)
  72. *!
  73. *!    create a menuitem-entry
  74. *!    BAR simply appends an itembar to the item-list
  75. *!    ADD creates a full menuitem-entry, if not already one
  76. *!        of the same name exists
  77. *!    CHECK also sets the menutoggle flag to an entry created
  78. *!        like ADD
  79. *!
  80. *!    You cannot add subitems to items that were created with
  81. *!        MENUADD or MENUCHECK as these have commands added
  82. *!        while we expect subitem carrier to have no command added
  83. *!    You cannot redefine the type of an menuitem once created
  84. *!        normal items can't be redefined to checkitems
  85. *!        or subitem carriers and vice versa
  86. *!
  87. *!    Since 22 Jun 1994 MENUADD incorporates MENU*BAR, MENU*CHECK, MENU*ADD
  88. *!        so MENUSUB(ADD|BAR|CHECK) are not really necessary any more
  89. *!        SUBnames       are splitted at ^S,
  90. *!        AMIGAshortcuts are splitted at ^A,
  91. *!        CHECKitems       are leaded    by ^C (at subs the last/sub name),
  92. *!        BARitems       are called       ^B (at subs the last/sub name)
  93. *!
  94. *!
  95. *! >MENUSUBADD     menuname itemname subname command  (obsolete)
  96. *! >MENUSUBBAR     menuname itemname            (obsolete)
  97. *! >MENUSUBCHECK menuname itemname subname command  (obsolete)
  98. *!
  99. *!    create a submenu-entry
  100. *!    SUBBAR simply appends an itembar to the subitem-list
  101. *!    SUBADD creates a full subitem-entry, if not already one
  102. *!        of the same name exists
  103. *!    SUBCHECK also sets the menutoggle flag to an entry created
  104. *!        like SUBADD
  105. *!
  106. *!    You cannot add subitems to items that were created with
  107. *!        MENUADD or MENUCHECK as these are managed in a quite
  108. *!        different way, so You create subitem-carrier simply by
  109. *!        using their names in a subitem definition
  110. *!    You cannot redefine the type of an subitem once created
  111. *!        normal subs can't be redefined to subcheck and vice versa
  112. *!    Since 22 Jun 1994 MENU*ADD incorporates MENU*BAR, MENU*CHECK, MENU*ADD
  113. *!        so MENU*(BAR|CHECK) are not really necessary any more
  114. *!        since MENUADD also handles subs, MENUSUBADD is obsolete, too
  115. *!
  116. *! >MENUSETITEM menuname itemname      status
  117. *! >MENUSETSUB    menuname itemname subname status    (obsolete)
  118. *! >MENUCHKITEM menuname itemname      variablename
  119. *! >MENUCHKSUB    menuname itemname subname variablename    (obsolete)
  120. *!
  121. *!    these commands set or check the satus of the (/sub)item-checked
  122. *!    flags for (sub)items created with the MENU(SUB)CHECK commands
  123. *!    status is one of 0|1/on|off the value set into variable is also 0|1
  124. *!        (again, please note, "toggle" is not yet supported)
  125. *!    Since 22 Jun 1994 MENU???ITEM is able to split its itemname at
  126. *!        SUBBREAK=^S, so MENU???SUB are not really neccessary any more.
  127. *!
  128. *! >MENUCLEAR
  129. *!
  130. *!    clean up the menustrip, i.e. delete all of its
  131. *!    menuheaders
  132. *!
  133. *! >MENUSAVE filename
  134. *!
  135. *!    save the menustrip as a file that can be
  136. *!    read by MENULOAD
  137. *!
  138. *! >MENULOAD filename
  139. *!
  140. *!    clear the menustrip and instead build a new
  141. *!    contents out of the file filename
  142. *!
  143. *! >MENUON
  144. *! >MENUOFF
  145. *!
  146. *!    show or hide the whole menustrip
  147. *!    MENUOFF is stackable, i.e You need as many MENUON calls
  148. *!    to show the menustrip as previously MENUOFF calls
  149. *!
  150. *!
  151. *!  MENUSTRIPS:
  152. *!  **********
  153. *!
  154. *!  the following commands do only make sense, if
  155. *!  You are using multiple menustrips
  156. *!  at [X]DME's start a menustrip called "default" is created;
  157. *!  for "normal" usage, that single strip may suffer.
  158. *!
  159. *!  Please note that the above MENU... commands apply to the
  160. *!  CURRENT menustrip (and only to it)
  161. *!
  162. *! >USEMENUSTRIP name
  163. *!
  164. *!    search for a certain menustrip and use it as the current one
  165. *!
  166. *! >REMMENUSTRIP
  167. *!
  168. *!    delete the current menustrip, if it is not the only one
  169. *!
  170. *! >NEWMENUSTRIP name
  171. *!
  172. *!    if there is already a menustrip called name,
  173. *!        simply call USEMENUSTRIP name
  174. *!    else create a new menustrip called name and use it
  175. *!
  176. *! NOTES about Menus
  177. *! -----------------
  178. *!
  179. *! CHANGE at 22 Jun 1994
  180. *! some commands become obsolete, but stay accessible for some patchlevels
  181. *! (for compability reasons)
  182. *! MENUSUBADD  replaces MENUSUBCHECK, MENUSUBBAR by ^C, ^B
  183. *! MENUADD     replaces MENUCHECK,    MENUBAR     by ^C, ^B
  184. *! MENUDELSUB  replaces MENUDELSUBBAR         by    ^B
  185. *! MENUDEL     replaces MENUDELSUB         by    ^B
  186. *! MENUADD     replaces MENUSUBADD         by       ^S
  187. *! MENUDEL     replaces MENUDELSUB         by       ^S
  188. *! MENUSETITEM replaces MENUSETSUB         by       ^S
  189. *! MENUCHKITEM replaces MENUCHKSUB         by       ^S
  190. *! so MENUADD, MENUDEL, MENUSETITEM, MENUCHKITEM should be enough
  191. *! the other commands might stay usable for a while, however, but they
  192. *! are not supported any more.
  193. *! please note, that we are introducing another Specialkey ^A to identify
  194. *! Amiga-Shortcuts
  195. *! please note, that MENUCHECK will not support ^A
  196. *! also note, that ^A, ^C are not really part of an Item's name, so
  197. *! menuitems must be deleted with ^C/^A stripped off.
  198. *!
  199. *! Finally I have to mention, that the variable access to menuitems
  200. *! does currently not use the same break-symbols as menuadd does;
  201. *! in var-access we still use "-" to separate itemnames from
  202. *! menunames and from subnames (for compability reasons). (if that
  203. *! functionality changes, we'll have to note it)
  204. *!
  205. *! as soon, as these obsolete declared commands are dropped
  206. *! we will support a set of macros in order to emulate them
  207. *! with the remaining commands, which offer even more functionality
  208. *!
  209.  
  210.     SEE ALSO
  211.     menustrips.c menu_dme.c menucontrol.c command.c
  212.  
  213.  
  214.     INDEX
  215.     $Header : $
  216.  
  217.     HISTORY
  218.     18 Dec 1992 b_null created
  219.     20 Dec 1992 b_null rewritten & documented
  220.     23 Jan 1993 b_null added menutomacro
  221.     25 Jan 1993 b_null added do_delmenu, do_itemcheck, do_subcheck
  222.     22 Jun 1994 null added support of check_symbol, short_cut
  223.     05-08-94    null added STATIC Command Interface
  224.     24-09-94 b_noll usage of std_-read/write-file
  225.     04-12-94 b_noll removed dead protos
  226.  
  227.     $Date: 1994/09/20 11:09:14 $ last update
  228.  
  229. ******************************************************************************/
  230.  
  231. /**************************************
  232.         Includes
  233. **************************************/
  234. #define  MENU_INTERNAL
  235. #include "defs.h"
  236. #include "menubase.h"
  237. #ifdef PATCH_NULL
  238. #include "COM.h"
  239. #endif
  240.  
  241.  
  242. /**************************************
  243.         Globale Variable
  244. **************************************/
  245.  
  246.  
  247. /**************************************
  248.       Interne Defines & Strukturen
  249. **************************************/
  250.  
  251. #define    SPLIT_CHECK_NAME(pn)     ((**pn==checkmark_Symbol) && ((*pn)++))
  252. #define SPLIT_SHORTCUT_NAME(pn,ps)  ((*ps=strchr(*pn,scutbreak_Symbol)) && ((**ps=0)||(*ps)++))
  253. #define  SPLIT_SUBITEM_NAME(pn,ps)  ((*ps=strchr(*pn, subbreak_Symbol)) && ((**ps=0)||(*ps)++))
  254. #define     IS_BAR_NAME(pn)     ((strcmp (*pn, barlabel_Symbol)==0)&&(*pn=BAR))
  255.  
  256.  
  257. /**************************************
  258.         Interne Variable
  259. **************************************/
  260.  
  261. /* fuer diese werte koennte ich sogar prefs-commandos basteln */
  262. char checkmark_Symbol = '\003'; /* in breakout: ^C for _C_heck    */
  263. char  subbreak_Symbol = '\023'; /* in breakout: ^S for _S_ub      */
  264. char scutbreak_Symbol = '\001'; /* in breakout: ^A for _A_miga    */
  265. char *barlabel_Symbol = "\002"; /* in breakout: ^B for _B_arlabel */
  266.  
  267. /**************************************
  268.        Interne Prototypes
  269. **************************************/
  270.  
  271.  
  272.  
  273. /*****************************************************************************
  274.  
  275.     NAME
  276.     do_delmenu
  277.  
  278.     PARAMETER
  279.     void
  280.  
  281.     RESULT
  282.     -/-
  283.  
  284.     RETURN
  285.     void
  286.  
  287.     DESCRIPTION
  288.     [X]DME command interface for
  289.  
  290.     NOTES
  291.  
  292.     BUGS
  293.  
  294.     EXAMPLES
  295.  
  296.     SEE ALSO
  297.  
  298.     INTERNALS
  299.  
  300.     HISTORY
  301.     25 Jan 1993 b_noll created
  302.  
  303. ******************************************************************************/
  304.  
  305. DEFUSERCMD("menudelhdr", 1, CF_VWM|CF_ICO, void, do_delmenu, (void),)
  306. {
  307.     menuoff (currentmenu(), currentwindow());
  308.     menudel (currentmenu(), GetArg(1));
  309.     menuon  (currentmenu(), currentwindow());
  310. } /* do_delmenu */
  311.  
  312.  
  313.  
  314. /*****************************************************************************
  315.  
  316.     NAME
  317.     do_itemadd
  318.  
  319.     PARAMETER
  320.     void
  321.  
  322.     RESULT
  323.     -/-
  324.  
  325.     RETURN
  326.     void
  327.  
  328.     DESCRIPTION
  329.     [X]DME command interface for
  330.  
  331.     NOTES
  332.     major change due to suggestion of Karl ...
  333.  
  334.     BUGS
  335.  
  336.     EXAMPLES
  337.  
  338.     SEE ALSO
  339.  
  340.     INTERNALS
  341.  
  342.     HISTORY
  343.     20 Dec 1992 b_noll created
  344.     22 Jun 1994 b_noll enhanced functionality - is now also subadd, check, bar,...
  345.  
  346. ******************************************************************************/
  347.  
  348. DEFUSERCMD("menuadd", 3, CF_VWM|CF_ICO, void, do_itemadd, (void),)
  349. {
  350.     char *iname, *sname, *scut;
  351.     int   chk;
  352.  
  353.     menuoff (currentmenu(), currentwindow());
  354.  
  355.     iname = GetArg(2);
  356.     SPLIT_SHORTCUT_NAME(&iname, &scut);
  357.  
  358.     if (SPLIT_SUBITEM_NAME(&iname, &sname)) {
  359.     chk = SPLIT_CHECK_NAME(&sname);
  360.     if (IS_BAR_NAME(&sname)) {
  361.         chk = 0;
  362.         scut = NULL;
  363.     } /* if */
  364.     subadd (currentmenu(), GetArg(1), iname, sname, GetArg(3), NULL, chk, scut);
  365.     } else {
  366.     chk = SPLIT_CHECK_NAME(&iname);
  367.     if (IS_BAR_NAME(&iname)) {
  368.         chk = 0;
  369.         scut = NULL;
  370.     } /* if */
  371.     itemadd (currentmenu(), GetArg(1), iname,       GetArg(3), NULL, chk, scut);
  372.     } /* if */
  373.  
  374.     menuon  (currentmenu(), currentwindow());
  375. } /* do_itemadd */
  376.  
  377.  
  378.  
  379. /*****************************************************************************
  380.  
  381.     NAME
  382.     do_itemcheck
  383.  
  384.     PARAMETER
  385.     void
  386.  
  387.     RESULT
  388.     -/-
  389.  
  390.     RETURN
  391.     void
  392.  
  393.     DESCRIPTION
  394.     [X]DME command interface for
  395.  
  396.     NOTES
  397.  
  398.     BUGS
  399.  
  400.     EXAMPLES
  401.  
  402.     SEE ALSO
  403.  
  404.     INTERNALS
  405.  
  406.     HISTORY
  407.     25 Jan 1993 b_noll created
  408.  
  409. ******************************************************************************/
  410.  
  411. DEFUSERCMD("menucheck", 3, CF_VWM|CF_ICO, void, do_itemcheck, (void),)
  412. {
  413.     char *iname, *sname;
  414.  
  415.     menuoff (currentmenu(), currentwindow());
  416.  
  417.     iname = GetArg(2);
  418.     if (SPLIT_SUBITEM_NAME(&iname, &sname)) {
  419.     if (IS_BAR_NAME(&sname));
  420.     subadd    (currentmenu(), GetArg(1), iname, sname, GetArg(3), NULL, 1, NULL);
  421.     } else {
  422.     if (IS_BAR_NAME(&iname));
  423.     itemadd (currentmenu(), GetArg(1), iname,        GetArg(3), NULL, 1, NULL);
  424.     } /* if */
  425.     menuon  (currentmenu(), currentwindow());
  426. } /* do_itemcheck */
  427.  
  428.  
  429.  
  430. /*****************************************************************************
  431.  
  432.     NAME
  433.     do_itembar
  434.  
  435.     PARAMETER
  436.     void
  437.  
  438.     RESULT
  439.     -/-
  440.  
  441.     RETURN
  442.     void
  443.  
  444.     DESCRIPTION
  445.     [X]DME command interface for
  446.  
  447.     NOTES
  448.  
  449.     BUGS
  450.  
  451.     EXAMPLES
  452.  
  453.     SEE ALSO
  454.  
  455.     INTERNALS
  456.  
  457.     HISTORY
  458.     20 Dec 1992 b_noll created
  459.  
  460. ******************************************************************************/
  461.  
  462. DEFUSERCMD("menubar", 1, CF_VWM|CF_ICO, void, do_itembar, (void),)
  463. {
  464.     menuoff (currentmenu(), currentwindow());
  465.     itemadd (currentmenu(), GetArg(1), BAR, NULL, NULL, 0, NULL);
  466.     menuon  (currentmenu(), currentwindow());
  467. } /* do_itembar */
  468.  
  469.  
  470.  
  471. /*****************************************************************************
  472.  
  473.     NAME
  474.     do_subadd
  475.  
  476.     PARAMETER
  477.     void
  478.  
  479.     RESULT
  480.     -/-
  481.  
  482.     RETURN
  483.     void
  484.  
  485.     DESCRIPTION
  486.     [X]DME command interface for
  487.  
  488.     NOTES
  489.  
  490.     BUGS
  491.  
  492.     EXAMPLES
  493.  
  494.     SEE ALSO
  495.  
  496.     INTERNALS
  497.  
  498.     HISTORY
  499.     20 Dec 1992 b_noll created
  500.     22 Jun 1994 b_noll enhanced functionality
  501.  
  502. ******************************************************************************/
  503.  
  504. DEFUSERCMD("menusubadd", 4, CF_VWM|CF_ICO, void, do_subadd, (void),)
  505. {
  506.     int chk;
  507.     char *sname, *scut;
  508.     menuoff (currentmenu(), currentwindow());
  509.  
  510.     sname = GetArg(3);
  511.        SPLIT_SHORTCUT_NAME(&sname, &scut);
  512.     chk = SPLIT_CHECK_NAME(&sname);
  513.     if (IS_BAR_NAME(&sname)) {
  514.     chk = 0;
  515.     scut = NULL;
  516.     } /* if */
  517.     subadd  (currentmenu(), GetArg(1), GetArg(2), sname, GetArg(4), NULL, chk, scut);
  518.     menuon  (currentmenu(), currentwindow());
  519. } /* do_subadd */
  520.  
  521.  
  522.  
  523. /*****************************************************************************
  524.  
  525.     NAME
  526.     do_subcheck
  527.  
  528.     PARAMETER
  529.     void
  530.  
  531.     RESULT
  532.     -/-
  533.  
  534.     RETURN
  535.     void
  536.  
  537.     DESCRIPTION
  538.     [X]DME command interface for
  539.  
  540.     NOTES
  541.  
  542.     BUGS
  543.  
  544.     EXAMPLES
  545.  
  546.     SEE ALSO
  547.  
  548.     INTERNALS
  549.  
  550.     HISTORY
  551.     25 Jan 1993 b_noll created
  552.  
  553. ******************************************************************************/
  554.  
  555. DEFUSERCMD("menusubcheck", 4, CF_VWM|CF_ICO, void, do_subcheck, (void),)
  556. {
  557.     menuoff (currentmenu(), currentwindow());
  558.     subadd  (currentmenu(), GetArg(1), GetArg(2), GetArg(3), GetArg(4), NULL, 1, NULL);
  559.     menuon  (currentmenu(), currentwindow());
  560. } /* do_subcheck */
  561.  
  562.  
  563.  
  564. /*****************************************************************************
  565.  
  566.     NAME
  567.     do_subbar
  568.  
  569.     PARAMETER
  570.     void
  571.  
  572.     RESULT
  573.     -/-
  574.  
  575.     RETURN
  576.     void
  577.  
  578.     DESCRIPTION
  579.     [X]DME command interface for
  580.  
  581.     NOTES
  582.  
  583.     BUGS
  584.  
  585.     EXAMPLES
  586.  
  587.     SEE ALSO
  588.  
  589.     INTERNALS
  590.  
  591.     HISTORY
  592.     20 Dec 1992 b_noll created
  593.  
  594. ******************************************************************************/
  595.  
  596. DEFUSERCMD("menusubbar", 2, CF_VWM|CF_ICO, void, do_subbar, (void),)
  597. {
  598.     menuoff (currentmenu(), currentwindow());
  599.     subadd  (currentmenu(), GetArg(1), GetArg(2), BAR, NULL, NULL, 0, NULL);
  600.     menuon  (currentmenu(), currentwindow());
  601. } /* do_subbar */
  602.  
  603.  
  604.  
  605. /*****************************************************************************
  606.  
  607.     NAME
  608.     do_delitem
  609.  
  610.     PARAMETER
  611.     void
  612.  
  613.     RESULT
  614.     -/-
  615.  
  616.     RETURN
  617.     void
  618.  
  619.     DESCRIPTION
  620.     [X]DME command interface for
  621.  
  622.     NOTES
  623.  
  624.     BUGS
  625.  
  626.     EXAMPLES
  627.  
  628.     SEE ALSO
  629.  
  630.     INTERNALS
  631.  
  632.     HISTORY
  633.     20 Dec 1992 b_noll created
  634.     22 Jun 1994 b_noll enhanced functionality
  635.  
  636. ******************************************************************************/
  637.  
  638. DEFUSERCMD("menudel", 2, CF_VWM|CF_ICO, void, do_delitem, (void),)
  639. {
  640.     char *iname, *sname;
  641.     menuoff (currentmenu(), currentwindow());
  642.     iname = GetArg(2);
  643.  
  644.     if (SPLIT_SUBITEM_NAME(&iname, &sname)) {
  645.     if (IS_BAR_NAME(&sname));
  646.     subdel    (currentmenu(), GetArg(1), iname, sname);
  647.     } else {
  648.     if (IS_BAR_NAME(&iname));
  649.     itemdel (currentmenu(), GetArg(1), iname);
  650.     } /* if */
  651.     menuon  (currentmenu(), currentwindow());
  652. } /* do_delitem */
  653.  
  654.  
  655.  
  656. /*****************************************************************************
  657.  
  658.     NAME
  659.     do_delitembar
  660.  
  661.     PARAMETER
  662.     void
  663.  
  664.     RESULT
  665.     -/-
  666.  
  667.     RETURN
  668.     void
  669.  
  670.     DESCRIPTION
  671.     [X]DME command interface for
  672.  
  673.     NOTES
  674.  
  675.     BUGS
  676.  
  677.     EXAMPLES
  678.  
  679.     SEE ALSO
  680.  
  681.     INTERNALS
  682.  
  683.     HISTORY
  684.     22 Dec 1992 b_noll created
  685.  
  686. ******************************************************************************/
  687.  
  688. DEFUSERCMD("menudelbar", 1, CF_VWM|CF_ICO, void, do_delitembar, (void),)
  689. {
  690.     menuoff (currentmenu(), currentwindow());
  691.     itemdel (currentmenu(), GetArg(1), BAR);
  692.     menuon  (currentmenu(), currentwindow());
  693. } /* do_delitembar */
  694.  
  695.  
  696.  
  697. /*****************************************************************************
  698.  
  699.     NAME
  700.     do_delsub
  701.  
  702.     PARAMETER
  703.     void
  704.  
  705.     RESULT
  706.     -/-
  707.  
  708.     RETURN
  709.     void
  710.  
  711.     DESCRIPTION
  712.     [X]DME command interface for
  713.  
  714.     NOTES
  715.  
  716.     BUGS
  717.  
  718.     EXAMPLES
  719.  
  720.     SEE ALSO
  721.  
  722.     INTERNALS
  723.  
  724.     HISTORY
  725.     20 Dec 1992 b_noll created
  726.     22 Jun 1994 b_noll enhanced functionality
  727.  
  728. ******************************************************************************/
  729.  
  730. DEFUSERCMD("menudelsub", 3, CF_VWM|CF_ICO, void, do_delsub, (void),)
  731. {
  732.     char *sname;
  733.     menuoff (currentmenu(), currentwindow());
  734.     sname = GetArg(3);
  735.     if (IS_BAR_NAME(&sname));
  736.     subdel  (currentmenu(), GetArg(1), GetArg(2), sname);
  737.     menuon  (currentmenu(), currentwindow());
  738. } /* do_delsub */
  739.  
  740.  
  741.  
  742. /*****************************************************************************
  743.  
  744.     NAME
  745.     do_delsubbar
  746.  
  747.     PARAMETER
  748.     void
  749.  
  750.     RESULT
  751.     -/-
  752.  
  753.     RETURN
  754.     void
  755.  
  756.     DESCRIPTION
  757.     [X]DME command interface for
  758.  
  759.     NOTES
  760.  
  761.     BUGS
  762.  
  763.     EXAMPLES
  764.  
  765.     SEE ALSO
  766.  
  767.     INTERNALS
  768.  
  769.     HISTORY
  770.     22 Dec 1992 b_noll created
  771.  
  772. ******************************************************************************/
  773.  
  774. DEFUSERCMD("menudelsubar", 2, CF_VWM|CF_ICO, void, do_delsubbar, (void),)
  775. {
  776.     menuoff (currentmenu(), currentwindow());
  777.     subdel  (currentmenu(), GetArg(1), GetArg(2), BAR);
  778.     menuon  (currentmenu(), currentwindow());
  779. } /* do_delsubbar */
  780.  
  781.  
  782.  
  783. /*****************************************************************************
  784.  
  785.     NAME
  786.     do_menuclear
  787.  
  788.     PARAMETER
  789.     void
  790.  
  791.     RESULT
  792.     -/-
  793.  
  794.     RETURN
  795.     void
  796.  
  797.     DESCRIPTION
  798.     [X]DME command interface for
  799.  
  800.     NOTES
  801.  
  802.     BUGS
  803.  
  804.     EXAMPLES
  805.  
  806.     SEE ALSO
  807.  
  808.     INTERNALS
  809.  
  810.     HISTORY
  811.     20 Dec 1992 b_noll created
  812.  
  813. ******************************************************************************/
  814.  
  815. DEFUSERCMD("menuclear", 0, CF_VWM|CF_ICO, void, do_menuclear, (void),)
  816. {
  817.     menuoff   (currentmenu(), currentwindow());
  818.     menuclear (currentmenu());
  819.     menuon    (currentmenu(), currentwindow());
  820. } /* do_menuclear */
  821.  
  822.  
  823.  
  824. /*****************************************************************************
  825.  
  826.     NAME
  827.     do_menuon
  828.  
  829.     PARAMETER
  830.     void
  831.  
  832.     RESULT
  833.     -/-
  834.  
  835.     RETURN
  836.     void
  837.  
  838.     DESCRIPTION
  839.     [X]DME command interface for
  840.  
  841.     NOTES
  842.  
  843.     BUGS
  844.  
  845.     EXAMPLES
  846.  
  847.     SEE ALSO
  848.  
  849.     INTERNALS
  850.  
  851.     HISTORY
  852.     20 Dec 1992 b_noll created
  853.  
  854. ******************************************************************************/
  855.  
  856. DEFUSERCMD("menuon", 0, CF_VWM|CF_ICO, void, do_menuon, (void),)
  857. {
  858.     menuon (currentmenu(), currentwindow());
  859. } /* do_menuon */
  860.  
  861.  
  862.  
  863. /*****************************************************************************
  864.  
  865.     NAME
  866.     do_menuoff
  867.  
  868.     PARAMETER
  869.     void
  870.  
  871.     RESULT
  872.     -/-
  873.  
  874.     RETURN
  875.     void
  876.  
  877.     DESCRIPTION
  878.     [X]DME command interface for
  879.  
  880.     NOTES
  881.  
  882.     BUGS
  883.  
  884.     EXAMPLES
  885.  
  886.     SEE ALSO
  887.  
  888.     INTERNALS
  889.  
  890.     HISTORY
  891.     20 Dec 1992 b_noll created
  892.  
  893. ******************************************************************************/
  894.  
  895. DEFUSERCMD("menuoff", 0, CF_VWM|CF_ICO, void, do_menuoff, (void),)
  896. {
  897.     menuoff (currentmenu(), currentwindow());
  898. } /* do_menuoff */
  899.  
  900.  
  901.  
  902. /*****************************************************************************
  903.  
  904.     NAME
  905.     do_menusave
  906.  
  907.     PARAMETER
  908.     void
  909.  
  910.     RESULT
  911.     -/-
  912.  
  913.     RETURN
  914.     void
  915.  
  916.     DESCRIPTION
  917.     [X]DME command interface for
  918.  
  919.     NOTES
  920.  
  921.     BUGS
  922.  
  923.     EXAMPLES
  924.  
  925.     SEE ALSO
  926.  
  927.     INTERNALS
  928.  
  929.     HISTORY
  930.     20 Dec 1992 b_noll created
  931.  
  932. ******************************************************************************/
  933.  
  934. static int _menusave (FILE *fo, APTR ms) {
  935.     savemenus (ms, fo);
  936.     return 1;
  937. } /* _menusave */
  938.  
  939. DEFUSERCMD("menusave", 1, CF_VWM|CF_ICO, void, do_menusave, (void),)
  940. {
  941.     menuoff     (currentmenu(), currentwindow());
  942.     std_writefile(_menusave, currentmenu());
  943.     menuon     (currentmenu(), currentwindow());
  944. } /* do_menusave */
  945.  
  946.  
  947.  
  948. /*****************************************************************************
  949.  
  950.     NAME
  951.     do_menuload
  952.  
  953.     PARAMETER
  954.     void
  955.  
  956.     RESULT
  957.     -/-
  958.  
  959.     RETURN
  960.     void
  961.  
  962.     DESCRIPTION
  963.     [X]DME command interface for
  964.  
  965.     NOTES
  966.  
  967.     BUGS
  968.  
  969.     EXAMPLES
  970.  
  971.     SEE ALSO
  972.  
  973.     INTERNALS
  974.  
  975.     HISTORY
  976.     20 Dec 1992 b_noll created
  977.  
  978. ******************************************************************************/
  979.  
  980. static int _menuload (FILE *fi, APTR ms) {
  981.     int    lineno = 0;
  982.     menuclear (ms);
  983.     loadmenus (ms, fi, &lineno);
  984.     return 1;
  985. } /* _menuload */
  986.  
  987. DEFUSERCMD("menuload", 1, CF_VWM|CF_ICO, void, do_menuload, (void),)
  988. {
  989.     menuoff    (currentmenu(), currentwindow());
  990.     std_readfile(_menuload, currentmenu());
  991.     menuon    (currentmenu(), currentwindow());
  992. } /* do_menuload */
  993.  
  994.  
  995.  
  996. /*****************************************************************************
  997.  
  998.     NAME
  999.     menutomacro
  1000.  
  1001.     PARAMETER
  1002.     char * str
  1003.  
  1004.     RESULT
  1005.     the command that is attached to the menu referred with str
  1006.  
  1007.     RETURN
  1008.     char *
  1009.  
  1010.     DESCRIPTION
  1011.     [X]DME vars interface for menu2macro
  1012.  
  1013.     NOTES
  1014.     that function was added 'cause in vars.c we use a
  1015.     table of all search-functions, and all the others
  1016.     do have only 1 argument
  1017.  
  1018.     BUGS
  1019.     never tested
  1020.  
  1021.     EXAMPLES
  1022.  
  1023.     SEE ALSO
  1024.  
  1025.     INTERNALS
  1026.  
  1027.     HISTORY
  1028.     22 Jan 1993 b_noll created
  1029.  
  1030. ******************************************************************************/
  1031.  
  1032. DEFVARTREE( 92, "MENU_", VAR_MEN, 5, 5, VF_COP, NULL, NULL, NULL, menutomacro )
  1033. Prototype char*menutomacro  (char*);
  1034. char *menutomacro (char *str)
  1035. {
  1036.     return (menu2macro (currentmenu(), str));
  1037. } /* menutomacro */
  1038.  
  1039.  
  1040.  
  1041. /*****************************************************************************
  1042.  
  1043.     NAME
  1044.     do_getcheckitem
  1045.  
  1046.     PARAMETER
  1047.     void
  1048.  
  1049.     RESULT
  1050.     -/-
  1051.  
  1052.     RETURN
  1053.     void
  1054.  
  1055.     DESCRIPTION
  1056.     [X]DME vars interface for
  1057.  
  1058.     NOTES
  1059.  
  1060.     BUGS
  1061.     never tested
  1062.  
  1063.     EXAMPLES
  1064.  
  1065.     SEE ALSO
  1066.  
  1067.     INTERNALS
  1068.  
  1069.     HISTORY
  1070.     25 Jan 1993 b_noll created
  1071.     22 Jun 1994 b_noll enhanced functionality
  1072.  
  1073. ******************************************************************************/
  1074.  
  1075. DEFUSERCMD("menugetcheck", 3, CF_VWM|CF_ICO, void, do_getcheckitem, (void),)
  1076. {
  1077.     int  v;
  1078.     char vv[2] = "0";
  1079.     char *iname, *sname;
  1080.  
  1081.     iname = GetArg(2);
  1082.     if (SPLIT_SUBITEM_NAME(&iname, &sname)) {
  1083.     v = chksubcheck  (currentmenu(), GetArg(1), iname, sname);
  1084.     } else {
  1085.     v = chkitemcheck (currentmenu(), GetArg(1), iname);
  1086.     } /* if */
  1087.  
  1088.     if (v >= 0) {
  1089.     vv[0] = v+48;
  1090.     SetTypedVar (GetArg(3), vv, VAR_GV);
  1091.     } else {
  1092. DEFMESSAGE( _MENU_checkitem_not_found, "%s:\n no check item of that name:\n %s-%s" )
  1093.     error (_MENU_checkitem_not_found, CommandName(), GetArg(1), GetArg(2));
  1094.     } /* if */
  1095. } /* do_getcheckitem */
  1096.  
  1097.  
  1098.  
  1099. /*****************************************************************************
  1100.  
  1101.     NAME
  1102.     do_getchecksub
  1103.  
  1104.     PARAMETER
  1105.     void
  1106.  
  1107.     RESULT
  1108.     -/-
  1109.  
  1110.     RETURN
  1111.     void
  1112.  
  1113.     DESCRIPTION
  1114.     [X]DME vars interface for
  1115.  
  1116.     NOTES
  1117.  
  1118.     BUGS
  1119.     never tested
  1120.  
  1121.     EXAMPLES
  1122.  
  1123.     SEE ALSO
  1124.  
  1125.     INTERNALS
  1126.  
  1127.     HISTORY
  1128.     25 Jan 1993 b_noll created
  1129.  
  1130. ******************************************************************************/
  1131.  
  1132. DEFUSERCMD("menugetscheck", 4, CF_VWM|CF_ICO, void, do_getchecksub, (void),)
  1133. {
  1134.     int  v;
  1135.     char vv[2] = "0";
  1136.  
  1137.     v = chksubcheck (currentmenu(), GetArg(1), GetArg(2), GetArg(3));
  1138.  
  1139.     if (v >= 0) {
  1140.     vv[0] = v+48;
  1141.     SetTypedVar (GetArg(4), vv, VAR_GV);
  1142.     } else {
  1143. DEFMESSAGE( _MENU_subcheck_not_found, "%s:\n no check sub item of that name:\n %s-%s-%s" )
  1144.     error (_MENU_subcheck_not_found, CommandName(), GetArg(1), GetArg(2), GetArg(3));
  1145.     } /* if */
  1146. } /* do_getchecksub */
  1147.  
  1148.  
  1149.  
  1150. /*****************************************************************************
  1151.  
  1152.     NAME
  1153.     do_setcheckitem
  1154.  
  1155.     PARAMETER
  1156.     void
  1157.  
  1158.     RESULT
  1159.     -/-
  1160.  
  1161.     RETURN
  1162.     void
  1163.  
  1164.     DESCRIPTION
  1165.     [X]DME vars interface for
  1166.  
  1167.     NOTES
  1168.  
  1169.     BUGS
  1170.     never tested
  1171.     toggle wont work
  1172.  
  1173.     EXAMPLES
  1174.  
  1175.     SEE ALSO
  1176.  
  1177.     INTERNALS
  1178.  
  1179.     HISTORY
  1180.     25 Jan 1993 b_noll created
  1181.     22 Jun 1994 b_noll enhanced functionality
  1182.  
  1183. ******************************************************************************/
  1184.  
  1185. DEFUSERCMD("menusetcheck", 3, CF_VWM|CF_ICO, void, do_setcheckitem, (void),)
  1186. {
  1187.     int v;
  1188.  
  1189.     char *iname, *sname;
  1190.     iname = GetArg(2);
  1191.     if (SPLIT_SUBITEM_NAME(&iname, &sname))
  1192.     v = setsubcheck (currentmenu(),  GetArg(1), iname, sname, test_arg(GetArg(3),1));
  1193.     else
  1194.     v = setitemcheck (currentmenu(), GetArg(1), iname,        test_arg(GetArg(3),1));
  1195.  
  1196.     if (v != RET_SUCC) {
  1197. DEFMESSAGE( _MENU_checkitem_not_found, "%s:\n no check item of that name:\n %s-%s" )
  1198.     error (_MENU_checkitem_not_found, CommandName(), GetArg(1), GetArg(2));
  1199.     } else {
  1200.     menu_strip (currentmenu(), Ep->win);
  1201.     } /* if */
  1202. } /* do_setcheckitem */
  1203.  
  1204.  
  1205.  
  1206. /*****************************************************************************
  1207.  
  1208.     NAME
  1209.     do_setchecksub
  1210.  
  1211.     PARAMETER
  1212.     void
  1213.  
  1214.     RESULT
  1215.     -/-
  1216.  
  1217.     RETURN
  1218.     void
  1219.  
  1220.     DESCRIPTION
  1221.     [X]DME vars interface for
  1222.  
  1223.     NOTES
  1224.  
  1225.     BUGS
  1226.     never tested
  1227.     toggle wont work
  1228.  
  1229.     EXAMPLES
  1230.  
  1231.     SEE ALSO
  1232.  
  1233.     INTERNALS
  1234.  
  1235.     HISTORY
  1236.     25 Jan 1993 b_noll created
  1237.  
  1238. ******************************************************************************/
  1239.  
  1240. DEFUSERCMD("menusetscheck", 4, CF_VWM|CF_ICO, void, do_setchecksub, (void),)
  1241. {
  1242.     int v;
  1243.     v = setsubcheck (currentmenu(), GetArg(1), GetArg(2), GetArg(3), test_arg(GetArg(4),1));
  1244.     if (v == RET_FAIL) {
  1245. DEFMESSAGE( _MENU_subcheck_not_found, "%s:\n no check sub item of that name:\n %s-%s-%s" )
  1246.     error (_MENU_subcheck_not_found, CommandName(), GetArg(1), GetArg(2), GetArg(3));
  1247.     } else {
  1248.     menu_strip (currentmenu(), Ep->win);
  1249.     } /* if */
  1250. } /* do_setchecksub */
  1251.  
  1252.  
  1253. /*****************************************************************************
  1254.  
  1255.     NAME
  1256.     do_new_menustrip
  1257.  
  1258.     PARAMETER
  1259.     void
  1260.  
  1261.     RESULT
  1262.     -/-
  1263.  
  1264.     RETURN
  1265.     void
  1266.  
  1267.     DESCRIPTION
  1268.     command interface for keyaddes/qualifier
  1269.  
  1270.     NOTES
  1271.     <never tested>
  1272.  
  1273.     BUGS
  1274.     <none known>
  1275.  
  1276.     EXAMPLES
  1277.  
  1278.     SEE ALSO
  1279.  
  1280.     INTERNALS
  1281.  
  1282.     HISTORY
  1283.     28 Jan 1993  b_null created
  1284.  
  1285. ******************************************************************************/
  1286.  
  1287. DEFUSERCMD("NewMenuStrip", 1, CF_VWM|CF_ICO|CF_COK, void, do_new_menustrip, (void),)
  1288. {
  1289.     MENUSTRIP * ms = new_menustrip (GetArg(1), 1);
  1290.  
  1291.     if (ms) {
  1292.     /* menuoff (currentmenu(), Ep->win); */
  1293.     Ep->menustrip = ms;
  1294.     menu_strip (currentmenu(), Ep->win);
  1295.     /* menuon  (currentmenu(), Ep->win); */
  1296.     } /* if */
  1297. } /* do_new_menustrip */
  1298.  
  1299.  
  1300.  
  1301. /*****************************************************************************
  1302.  
  1303.     NAME
  1304.     do_del_menustrip
  1305.  
  1306.     PARAMETER
  1307.     void
  1308.  
  1309.     RESULT
  1310.     -/-
  1311.  
  1312.     RETURN
  1313.     void
  1314.  
  1315.     DESCRIPTION
  1316.     command interface for keyaddes/qualifier
  1317.  
  1318.     NOTES
  1319.     <never tested>
  1320.  
  1321.     for that function is highly dangerous it has been disabled
  1322.  
  1323.  
  1324.     BUGS
  1325.     <none known>
  1326.  
  1327.     EXAMPLES
  1328.  
  1329.     SEE ALSO
  1330.  
  1331.     INTERNALS
  1332.  
  1333.     HISTORY
  1334.     28 Jan 1993  b_null created
  1335.  
  1336. ******************************************************************************/
  1337.  
  1338.  DEFUSERCMD("DelMenuStrip", 0, CF_VWM|CF_ICO|CF_COK, void, do_del_menustrip, (void),)
  1339. {
  1340.     MENUSTRIP * ms = currentmenu ();
  1341.     MENUSTRIP * ns;
  1342.     ED          * ep;
  1343.  
  1344.     menuoff (ms, Ep->win);          /* remove all strips */
  1345.  
  1346.     delete_menustrip (ms, 0);
  1347.     ns = get_menustrip (NULL);
  1348.  
  1349.     for (ep = GetHead (&DBase); ep; ep = GetSucc (ep)) {
  1350.     if (ep->menustrip == ms) {
  1351.         ep->menustrip = NULL; /* ns */
  1352.     } /* if */
  1353.     } /* for */
  1354.  
  1355.     menuoff (ns, Ep->win);          /* this is def_too != 0 since */
  1356.     menuon  (ns, Ep->win);          /* ns == get_menustrip(NULL)  */
  1357. } /* do_del_menustrip */
  1358.  
  1359.  
  1360.  
  1361. /*****************************************************************************
  1362.  
  1363.     NAME
  1364.     do_use_menustrip
  1365.  
  1366.     PARAMETER
  1367.     void
  1368.  
  1369.     RESULT
  1370.     -/-
  1371.  
  1372.     RETURN
  1373.     void
  1374.  
  1375.     DESCRIPTION
  1376.     command interface for keyaddes/qualifier
  1377.  
  1378.     NOTES
  1379.     <never tested>
  1380.  
  1381.     BUGS
  1382.     <none known>
  1383.  
  1384.     EXAMPLES
  1385.  
  1386.     SEE ALSO
  1387.  
  1388.     INTERNALS
  1389.  
  1390.     HISTORY
  1391.     28 Jan 1993  b_null created
  1392.  
  1393. ******************************************************************************/
  1394.  
  1395. DEFUSERCMD("UseMenuStrip", 1, CF_VWM|CF_ICO|CF_COK, void, do_use_menustrip, (void),)
  1396. {
  1397.     MENUSTRIP * ms = get_menustrip (GetArg (1));
  1398.  
  1399.     if (ms) {
  1400.     Ep->menustrip = ms;
  1401.     menu_strip (ms, Ep->win);
  1402.     } /* if */
  1403. } /* do_use_menustrip */
  1404.  
  1405.  
  1406.  
  1407.  
  1408.  
  1409. /*****************************************************************************
  1410.  
  1411.     NAME
  1412.     menufind
  1413.     menugethelp
  1414.     menusethelp
  1415.     menugetcommand
  1416.     menusetcommand
  1417.     menucall
  1418.  
  1419.     PARAMETER
  1420.  
  1421.     RESULT
  1422.  
  1423.     RETURN
  1424.  
  1425.     DESCRIPTION
  1426.     interfaces to support handles used by the
  1427.     STATIC Command Interface
  1428.     in order to enable use of COMTREE menu
  1429.     as well as VARTREE menucomm/menuhelp
  1430.  
  1431.     NOTES
  1432.     <never tested>
  1433.  
  1434.     BUGS
  1435.     <none known>
  1436.  
  1437.     EXAMPLES
  1438.  
  1439.     SEE ALSO
  1440.  
  1441.     INTERNALS
  1442.  
  1443.     HISTORY
  1444.     05-08-94 null created
  1445.  
  1446. ******************************************************************************/
  1447.  
  1448. #ifdef STATIC_COM
  1449.  
  1450.  
  1451.  Prototype APTR menufind (char *name);
  1452. APTR menufind (char *name) {
  1453.     return findmenu(currentmenu(), name);
  1454. } /* menufind */
  1455.  
  1456.  Prototype char *menugethelp(APTR handle);
  1457. char *menugethelp(APTR handle) {
  1458.     return ((XITEM *)handle)->help;
  1459. } /* menugethelp */
  1460.  
  1461.  Prototype char *menugetcommand(APTR handle);
  1462. char *menugetcommand(APTR handle) {
  1463.     return ((XITEM *)handle)->com;
  1464. } /* menugetcommand */
  1465.  
  1466.  Prototype char *menusetcommand(APTR handle, char *val);
  1467. char *menusetcommand(APTR handle, char *val) {
  1468.     char *ptr;
  1469.     if (ptr = DupFunc(val)) {
  1470.     DeallocFunc(((XITEM *)handle)->com);
  1471.     ((XITEM *)handle)->com = ptr;
  1472.     return TRUE;
  1473.     } /* if */
  1474.     nomemory();
  1475.     return FALSE;
  1476. } /* menusetcommand */
  1477.  
  1478.  Prototype char *menusethelp (APTR handle, char *val);
  1479. char *menusethelp (APTR handle, char *val) {
  1480.     char *ptr;
  1481.     if (ptr = DupFunc(val)) {
  1482.     DeallocFunc(((XITEM *)handle)->help);
  1483.     ((XITEM *)handle)->help = ptr;
  1484.     return TRUE;
  1485.     } /* if */
  1486.     nomemory();
  1487.     return FALSE;
  1488. } /* menusethelp */
  1489.  
  1490.  Prototype int menucall (APTR handle);
  1491. int menucall (APTR handle) {
  1492.     char *ptr;
  1493.     if (ptr = strdup(menugetcommand(handle))) {
  1494.     retval = do_command(ptr);
  1495.     free (ptr);
  1496.     return OK;
  1497.     } /* if */
  1498.     nomemory();
  1499.     return FALSE;
  1500. } /* menucall */
  1501.  
  1502. #endif /* STATIC_COM */
  1503.  
  1504.  
  1505.  
  1506. /******************************************************************************
  1507. *****  ENDE menucom.c
  1508. ******************************************************************************/
  1509.